<?php
$model = new BDynamicFormModel();
$model->addField('addRole');
$form = $this->beginWidget('CActiveForm', array(
    "id" => "manage-addRole-form",
    'enableAjaxValidation' => FALSE,
    'htmlOptions' => array('class' => '', 'role' => 'form'),
        ));
?>
<style>
    @media (min-width: 768px){
        .roleList {
            margin-right: 0;
            margin-left: 0;
            background-color: #fff;
            border-color: #ddd;
            border-width: 1px;
            border-radius: 4px 4px 0 0;
            -webkit-box-shadow: none;
            box-shadow: none;
        }
    }
</style>
<legend>
    <h4><?php
        echo $control->getAjaxLink(array('name' => '功能列表', 'id' => 'showEventList'), array(
            'cooker' => 'BAEvent@showEventList'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink('设置权限首页', array(
            'cooker' => 'BAEvent@showEventHome'
        ));
        ?>\
        <?php
        echo $control->getAjaxLink('用户角色列表', array(
            'cooker' => 'BAMembership@showSpaceUserRoleList'
        ));
        ?>\
        机构角色列表 
    </h4>
</legend>
<div><h3<small>用户名：<?php $user = new BUser($userId);
        echo $user->getName();
        ?></small></h3></div>
<div class="">
    <div class="roleList">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th></th>
                    <th>分类</th>
                    <th>全名</th>
                    <th>应用</th>
                    <th>名称</th>
                </tr>
            </thead>
            <tbody>
                <?php
                foreach ($userJoinableRoleData as $id => $role) {
                    $appId = $role->appId;
                    $app = BApp::getAppById($appId);
                    $appClass = get_class($app);
                    $fullName = $role->getFullName();
                    $roleAlias = BARoleCooker::getRoleAliasByFullName($fullName);
                    $fullName = str_replace('app_root.', '', $fullName);
                    ?>
                    <tr>
                        <td><?php echo CHtml::activeCheckBox($model, "[$id]addRole"); ?></td>
                        <td><?php echo '客户角色'; ?></td>
                        <td><?php echo $fullName; ?></td>
                        <td><?php echo yii::t('site', $appClass); ?></td>
                        <td><?php echo $roleAlias; ?></td>
                    </tr>
<?php } ?>
            </tbody>
        </table>
    </div>
    <div>
        <?php
        echo $control->getAjaxLink('添加用户角色', array('cooker' => 'BAMembership@addUserRole',
            'userId' => $userId,
            'htmlOptions' => array('class' => 'btn')));
        ?>
    </div>
</div>
<?php $this->endWidget(); ?>